import instance from '../http'


export const getCategories = (type="") => {
    let url = "/categories/"
    if(type!=""){
        url += "?type="+type
    }
    return instance({
        url,
        method: "get"
    })
}

export const addCategory = (data) => {
    return instance({
        url: "/categories/",
        method: "post",
        data
    })
}

export const updateCategory = (id, data) => {
    return instance({
        url: "/categories/" + id + "/",
        method: "put",
        data
    })
}

export const deleteCategory = (id) => {
    return instance({
        url: "/categories/" + id + "/",
        method: "delete",
    })
}

export const deleteCategories = (ids) => {
    return instance({
        url: "/categories/",
        method: "delete",
        data:ids
    })
}

export const addArticles = (id, articles)=>{
    return instance({
        url:"/categories/" + id + "/add_articles/",
        method:"post",
        data:articles
    })
}